package com.tanhua.server.controller;

import com.tanhua.model.soul.Answers;
import com.tanhua.model.soul.ListVo;
import com.tanhua.model.soul.ReportVo;
import com.tanhua.server.service.TestSoulService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import javax.ws.rs.GET;
import java.util.List;
import java.util.Map;


@RestController
@RequestMapping("/testSoul")
public class TestSoulController {
    @Autowired
        private TestSoulService testSoulService;

    /**
     * 问卷列表
     * @return
     */
    @GetMapping
    public ResponseEntity findList(){
         List<ListVo> listVo = testSoulService.findListAndProblem();
        return ResponseEntity.ok(listVo);
    }

    /**
     *提交问卷
     * @param map
     * @return
     */
    @PostMapping
    public ResponseEntity submitList(@RequestBody Map<String,List<Answers>> map){

        String s = testSoulService.submitList(map);
        return ResponseEntity.ok(s);
    }

    /**
     * 查看结果
     * @param id
     * @return
     */
    @GetMapping("/report/{id}")
    public ResponseEntity getReport(@PathVariable Long id){
        ReportVo reportVo = testSoulService.reportResult(id);
        return ResponseEntity.ok(reportVo);
    }

}
